package com.zmyuan.quartz.db.demo;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by zhudebin on 16/7/20.
 */
public class HelloJob implements StatefulJob {

    public static final String IDX = "idx_xxx";

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        int id = jobExecutionContext.getMergedJobDataMap().getInt(IDX);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(id + " ---------hello--------" + sdf.format(new Date()));
        jobExecutionContext.getJobDetail().getJobDataMap().put(IDX, ++id + "");
    }
}